//首页
const express = require('express')
//引入连接池
const pool = require('../pool')
const router = express.Router()
router.get('/plan_tit/', (req, res, next) => {
    var obj = req.query
    pool.query('select * from plan_tit', [obj.aid], (err, r) => {
        if (err) {
            return next(err)
        }
        res.send({ code: 200, msg: '首页筛选', data: r })
    })
})
router.get('/plan_det/1/', (req, res, next) => {
    var obj = req.query
    pool.query('select * from plan_det where plan_1=1', [obj.aid], (err, r) => {
        if (err) {
            return next(err)
        }
        res.send({
            code: 200, msg: '目的地', data: r
        })
    })
})
router.get('/plan_det/2/', (req, res, next) => {
    var obj = req.query
    pool.query('select * from plan_det where plan_1=2', [obj.aid], (err, r) => {
        if (err) {
            return next(err)
        }
        res.send({
            code: 200, msg: '出行时间', data: r
        })
    })
})
router.get('/plan_det/3/', (req, res, next) => {
    var obj = req.query
    pool.query('select * from plan_det where plan_1=3', [obj.aid], (err, r) => {
        if (err) {
            return next(err)
        }
        res.send({
            code: 200, msg: '出行天数', data: r
        })
    })
})
router.get('/plan_det/4/', (req, res, next) => {
    var obj = req.query
    pool.query('select * from plan_det where plan_1=4', [obj.aid], (err, r) => {
        if (err) {
            return next(err)
        }
        res.send({
            code: 200, msg: '出发城市', data: r
        })
    })
})
router.get('/plan_det/5/', (req, res, next) => {
    var obj = req.query
    pool.query('select * from plan_det where plan_1=5', [obj.aid], (err, r) => {
        if (err) {
            return next(err)
        }
        res.send({
            code: 200, msg: '行程主题', data: r
        })
    })
})
router.get('/plan_det/6/', (req, res, next) => {
    var obj = req.query
    pool.query('select * from plan_det where plan_1=6', [obj.aid], (err, r) => {
        if (err) {
            return next(err)
        }
        res.send({
            code: 200, msg: '精华等级', data: r
        })
    })
})
router.get('/detail/1/', (req, res, next) => {
    var obj = req.query
    pool.query('select * from detail where pages=1', [obj.aid], (err, r) => {
        if (err) {
            return next(err)
        }
        res.send({
            code: 200, msg: '详情', data: r, pages: r[0].pages
        })
    })
})





















module.exports = router